package com.zgjkhis.modules.system.service.mapper;


import com.zgjkhis.common.mapper.CoreMapper;
import com.zgjkhis.modules.system.domain.Schedule;
import com.zgjkhis.modules.system.service.dto.ScheduleQueryCriteria;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @date 2020-05-14
*/
@Repository
public interface ScheduleMapper extends CoreMapper<Schedule> {
    @Select("<script>select * from schedule t where 1=1 \n" +

            "<if test=\"schedule.responsibleUserName!=null and schedule.responsibleUserName!=''\">\n" +
            "\t and (t.responsible_user_name LIKE CONCAT('%',#{schedule.responsibleUserName},'%') )\n" +
            "</if>\n" +
            "<if test=\"schedule.contentName!=null and schedule.contentName!=''\">\n" +
            "\t and (t.content_name LIKE CONCAT('%',#{schedule.contentName},'%') )\n" +
            "</if>\n" +
            "<if test = \"schedule.status != null and schedule.status!=''\">\n" +
            "\tand t.status = #{schedule.status}\n" +
            "</if>\n" +
            "<if test = \"schedule.pharmacyId != null and schedule.pharmacyId!=''\">\n" +
            "\tand t.pharmacy_id = #{schedule.pharmacyId}\n" +
            "</if>\n" +
            "<if test = \"schedule.startPlanTime != null and schedule.startPlanTime!=''\">\n" +
            " and t.plan_time BETWEEN #{schedule.startPlanTime} and #{schedule.endPlanTime}\n" +
            "</if>\n" +
            "</script>")
    List<Schedule> findAllByPageable(@Param("schedule") ScheduleQueryCriteria criteria);


}
